The Number of Symbol Comparisons in QuickSort and QuickSelect
نویسندگان
چکیده
We revisit the classical QuickSort and QuickSelect algorithms, under a complexity model that fully takes into account the elementary comparisons between symbols composing the records to be processed. Our probabilistic models belong to a broad category of information sources that encompasses memoryless (i.e., independent-symbols) and Markov sources, as well as many unbounded-correlation sources. We establish that, under our conditions, the average-case complexity of QuickSort is O(n log n) [rather than O(n log n), classically], whereas that of QuickSelect remains O(n). Explicit expressions for the implied constants are provided by our combinatorial–analytic methods.
منابع مشابه
Randomized Algorithms: QuickSort and QuickSelect
Let Q(A) be number of comparisons done on input array A: (A) For 1 ≤ i < j < n let R ij be the event that rank i element is compared with rank j element. (B) X ij is the indicator random variable for R ij. That is, X ij = 1 if rank i is compared with rank j element, otherwise 0. Q(A) = ∑ 1≤i<j≤n X ij and hence by linearity of expectation,
متن کاملRandomized Algorithms: QuickSort and QuickSelect
(A) Let Q(A) be number of comparisons done on input array A: (A) R ij : event that rank i element is compared with rank j element, for 1 ≤ i < j ≤ n. (B) X ij is the indicator random variable for R ij. That is, X ij = 1 if rank i is compared with rank j element, otherwise 0. (B) Q(A) = ∑ 1≤i<j≤n X ij. (C) By linearity of expectation,
متن کاملRandomized Algorithms: QuickSort and QuickSelect
Let Q(A) be number of comparisons done on input array A: (A) For 1 ≤ i < j < n let R ij be the event that rank i element is compared with rank j element. (B) X ij is the indicator random variable for R ij. That is, X ij = 1 if rank i is compared with rank j element, otherwise 0. Q(A) = ∑ 1≤i<j≤n X ij and hence by linearity of expectation,
متن کاملTowards Optimal Multiple Selection
The multiple selection problem asks for the elements of rank r1, r2, . . . , rk from a linearly ordered set of n elements. Let B denote the information theoretic lower bound on the number of element comparisons needed for multiple selection. We first show that a variant of multiple quickselect — a well known, simple, and practical generalization of quicksort — solves this problem with B + O(n) ...
متن کاملOptimal Sampling Strategies in Quicksort and Quickselect
It is well known that the performance of quicksort can be improved by selecting the median of a sample of elements as the pivot of each partitioning stage. For large samples the partitions are better, but the amount of additional comparisons and exchanges to find the median of the sample also increases. We show in this paper that the optimal sample size to minimize the average total cost of qui...
متن کامل